package com.kaka.bus;

import com.google.gson.Gson;
import com.kaka.bus.bean.City;
import com.kaka.bus.di.DataManager;
import com.kaka.bus.manager.T;
import com.kaka.bus.mvp.RxPresenter;
import com.kaka.bus.util.logger.Logger;

import javax.inject.Inject;

import io.reactivex.subscribers.ResourceSubscriber;

/**
 * Created by zhangqi on 2017/12/20.
 * e-mail : ${email}
 * desc :
 */

public class MainPresenter extends RxPresenter<MainContract.View> implements MainContract.Presenter {

    @Inject
    public MainPresenter(DataManager dataManager) {
        super(dataManager);
    }

    @Override
    public void getCity() {
        mView.showDialog("呵呵");
        addSubscribe(mDataManager.getApi().getCity().compose(T.<City>D()).subscribeWith(new ResourceSubscriber<City>() {
            @Override
            public void onNext(City city) {
                Logger.i(new Gson().toJson(city));
            }

            @Override
            public void onError(Throwable t) {

            }

            @Override
            public void onComplete() {

            }
        }));
    }
}
